package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Monitor;
import com.ruoyi.system.service.IMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班组长资格Controller
 * 
 * @author WEI&WU
 * @date 2024-05-25
 */
@RestController
@RequestMapping("/system/monitor")
public class MonitorController extends BaseController
{
    @Autowired
    private IMonitorService monitorService;

    /**
     * 查询班组长资格列表
     */
    @PreAuthorize("@ss.hasPermi('system:monitor:list')")
    @GetMapping("/list")
    public TableDataInfo list(Monitor monitor)
    {
        startPage();
        List<Monitor> list = monitorService.selectMonitorList(monitor);
        return getDataTable(list);
    }

    /**
     * 导出班组长资格列表
     */
    @PreAuthorize("@ss.hasPermi('system:monitor:export')")
    @Log(title = "班组长资格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Monitor monitor)
    {
        List<Monitor> list = monitorService.selectMonitorList(monitor);
        ExcelUtil<Monitor> util = new ExcelUtil<Monitor>(Monitor.class);
        util.exportExcel(response, list, "班组长资格数据");
    }

    /**
     * 获取班组长资格详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:monitor:query')")
    @GetMapping(value = "/{employeeId}")
    public AjaxResult getInfo(@PathVariable("employeeId") Long employeeId)
    {
        return success(monitorService.selectMonitorByEmployeeId(employeeId));
    }

    /**
     * 新增班组长资格
     */
    @PreAuthorize("@ss.hasPermi('system:monitor:add')")
    @Log(title = "班组长资格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Monitor monitor)
    {
        return toAjax(monitorService.insertMonitor(monitor));
    }

    /**
     * 修改班组长资格
     */
    @PreAuthorize("@ss.hasPermi('system:monitor:edit')")
    @Log(title = "班组长资格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Monitor monitor)
    {
        return toAjax(monitorService.updateMonitor(monitor));
    }

    /**
     * 删除班组长资格
     */
    @PreAuthorize("@ss.hasPermi('system:monitor:remove')")
    @Log(title = "班组长资格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{employeeIds}")
    public AjaxResult remove(@PathVariable Long[] employeeIds)
    {
        return toAjax(monitorService.deleteMonitorByEmployeeIds(employeeIds));
    }
}
